package com.xoa.controller.financialManage.charge;

import com.xoa.model.financialManage.charge.ChargeType;
import com.xoa.service.financialManage.charge.ChargeTypeService;
import com.xoa.util.ToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 费用类型 前端控制器
 * </p>
 *
 * @author liujian
 * @since 2020-04-23
 */
@RestController
@RequestMapping("/chargeType")
public class ChargeTypeController {

    @Autowired
    ChargeTypeService chargeTypeService;

    //新增费用类型
    @RequestMapping("/saveChargeType")
    public ToJson saveChargeType(@RequestBody ChargeType chargeType){
        return chargeTypeService.save(chargeType);
    }

    //删除费用类型
    @RequestMapping("/delChargeType")
    public ToJson delChargeType(Integer chargeTypeId){
        return chargeTypeService.deleteById(chargeTypeId);
    }

    //编辑费用类型
    @RequestMapping("/editChargeType")
    public ToJson editChargeType(ChargeType chargeType){
        return chargeTypeService.update(chargeType);
    }

    //根据ID查询费用类型
    @RequestMapping("/findChargeTypeById")
    public ToJson editChargeType(Integer chargeTypeId){
        return chargeTypeService.selectById(chargeTypeId);
    }

    //根据ID查询费用子类型
    @RequestMapping("/findChargeTypeByParent")
    public ToJson findChargeTypeByParent(Integer chargeTypeParent){
        return chargeTypeService.selectByParent(chargeTypeParent);
    }

    //查询费用一级类型
    @RequestMapping("/selectChargeType")
    public ToJson selectChargeType(boolean type){
        return chargeTypeService.selectChargeType(type);
    }

}